package controllers

import (
	"github.com/astaxie/beego"
	"beeblog/models"
)

type ReplayControllers struct {
	beego.Controller
}

func (this *ReplayControllers) Add()  {
       tid := this.Input().Get("tid")
       name := this.Input().Get("nickname")
       content := this.Input().Get("content")

       err := models.AddReplay(tid,name,content)

       if err != nil{
       	beego.Error(err)
	   }

	   this.Redirect("/topic/view/"+tid,302)
}

func (this *ReplayControllers) Delete()  {
	id := this.Input().Get("rid")
	err := models.DeleteReplay(id)
	if err != nil{
		beego.Error(err)
	}

	tid := this.Input().Get("tid")
	this.Redirect("/topic/view/"+tid,301)
	return
}